package cn.shadow.thread;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class Atomic {
    public static void main(String[] args) {
        AtomicInteger count = new AtomicInteger(0);
        int get = count.incrementAndGet();
        System.out.println(get);
        Lock lock = new ReentrantLock(true);
        for (int i = 0; i < 10; i++) {
            Thread thread = new Thread(() -> {
                lock.lock();
                System.out.println("thread=%s" + Thread.currentThread().getName());
                lock.unlock();
            });
            thread.start();
        }

    }
}
